package cn.ncu.wechat.service.impl;

import cn.ncu.wechat.util.Result;
import cn.ncu.wechat.vo.PointsRecordVo;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import cn.ncu.wechat.model.PointsRecord;
import cn.ncu.wechat.service.PointsRecordService;
import cn.ncu.wechat.dao.PointsRecordMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author
* @description 针对表【points_record(积分记录表)】的数据库操作Service实现
* @createDate 2025-01-07 16:16:02
*/
@Service
public class PointsRecordServiceImpl extends ServiceImpl<PointsRecordMapper, PointsRecord>
    implements PointsRecordService{
    @Autowired
    private PointsRecordMapper pointsRecordMapper;
    public Result<?> GetRecord(Integer page, Integer pageSize, Integer memberId, Integer type){
        Page<PointsRecordVo> pageInfo = new Page<>(page, pageSize);
        Page<PointsRecordVo> pointsRecords = pointsRecordMapper.GetPointRecordByKey(pageInfo,type,memberId);
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("total",pointsRecords.getTotal());
        jsonObject.put("list",pointsRecords.getRecords());
        return Result.success(jsonObject);
    }
}




